using System;
using System.Collections.Generic;


namespace AHWrapper{
	public class Investigator{
	
	//-------------------CLASS VARIABLES-------------------------//
		public string name{get;set;}
	
		public string curLocName;
		public string homeLocName;
	
		//public inventory inventory;
		public bool delayed;
		
		public int agility{get;set;}
		public bool inPlay;
		public int movesLeft{get;set;}
		public bool devoured;
		public string invImgLoc;
		public List<Mons> mTroph;
		
		
		public int[,] stats;
		
		
		
		
		
	

	
	
	
//-------------------CONSTRUCTORS----------------------------//	
		public Investigator(){
		}
	
		public Investigator(string name, int mSan, int mStam, string home, 
							int maxLore, int minLore, int maxWill, int minWill, int maxFight, int minFight,
							int maxLuck, int minLuck, int maxSpeed, int minSpeed, int maxSneak, int minSneak, 
							int pAgility, string invImg){
			

			
			stats = new int[8,3];
			
			stats[Constants.Sanity,Constants.Max]=mSan;
			stats[Constants.Sanity,Constants.Cur]=mSan;
			stats[Constants.Sanity,Constants.Min]=0;
			stats[Constants.Stamina,Constants.Max]=mStam;
			stats[Constants.Stamina,Constants.Cur]=mStam;
			stats[Constants.Stamina,Constants.Min]=0;
			stats[Constants.Sneak,Constants.Min]=minSneak;
			stats[Constants.Sneak,Constants.Cur]=maxSneak;
			stats[Constants.Sneak,Constants.Max]=maxSneak;
			stats[Constants.Speed,Constants.Min]=minSpeed;
			stats[Constants.Speed,Constants.Cur]=minSpeed;
			stats[Constants.Speed,Constants.Max]=maxSpeed;
			stats[Constants.Will,Constants.Min]=minWill;
			stats[Constants.Will,Constants.Cur]=minWill;
			stats[Constants.Will,Constants.Max]=maxWill;
			stats[Constants.Fight,Constants.Min]=minFight;
			stats[Constants.Fight,Constants.Cur]=maxFight;
			stats[Constants.Fight,Constants.Max]=maxFight;
			stats[Constants.Lore,Constants.Min]=minLore;
			stats[Constants.Lore,Constants.Cur]=minLore;
			stats[Constants.Lore,Constants.Max]=maxLore;
			stats[Constants.Luck,Constants.Min]=minLuck;
			stats[Constants.Luck,Constants.Cur]=maxLuck;
			stats[Constants.Luck,Constants.Max]=maxLuck;
			
			
			
			mTroph=new List<Mons>();
			
			curLocName=home;
			homeLocName=home;
			delayed=false;
			agility=pAgility;
			movesLeft=0;
			devoured=false;
			invImgLoc=invImg;
		
			
		}
	
	
		public string getHome(){
			return homeLocName;
		}
	
		public string getPosition(){
			return curLocName;
		}
	
		public void setPostion(string destination){
			curLocName=destination;
		}
		public bool setStats(int pSpeed,int pFight, int pLore, bool firstUpkeep){
			int total=Math.Abs(pSpeed-stats[Constants.Speed,Constants.Cur])+
					  Math.Abs(pFight-stats[Constants.Fight,Constants.Cur])+
					  Math.Abs(pLore-stats[Constants.Lore,Constants.Cur]);
			if( total < this.agility || firstUpkeep){
				stats[Constants.Speed,Constants.Cur]=pSpeed;
				stats[Constants.Fight,Constants.Cur]=pFight;
				stats[Constants.Lore,Constants.Cur]=pLore;
				stats[Constants.Sneak,Constants.Cur]=stats[Constants.Sneak,Constants.Max]-(pSpeed-stats[Constants.Speed,Constants.Min]);
				stats[Constants.Will,Constants.Cur]=stats[Constants.Will,Constants.Max]-(pFight-stats[Constants.Fight,Constants.Min]);
				stats[Constants.Luck,Constants.Cur]=stats[Constants.Luck,Constants.Max]-(pLore-stats[Constants.Lore,Constants.Min]);
				return true;
			}else{
				return false;
			}		
		}
		public int getMovesLeft(){
			return movesLeft;
		}
		public void resetMoves(){
			movesLeft=stats[Constants.Speed,Constants.Cur];
		}
		public void stopMoves(){
			movesLeft=0;		
		}
		public void moved(){
			movesLeft--;
		}
		
		public bool check(int pStat, int pModifier){
			Random rand = new Random();
			int x;
			for(int i=0; i<(stats[pStat,Constants.Cur]+pModifier); i++){
				x=rand.Next(1,6);
				if(x>3){
					return true;
				}
			}
			return false;
		}
		
		public void addMTroph(Mons pTroph){
			mTroph.Add(pTroph);
		}
	}	
}

